<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>网络科学中国</title>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<?php
//session_start();
include_once("config.inc.php");
if($_POST){
	if (is_file("./filterwords.txt")){					//判断给定文件名是否为一个正常的文件
	    $filter_word = file("./filterwords.txt");		//把整个文件读入一个数组中
		$content=$_POST['content'];
		for($i=0;$i<count($filter_word);$i++){			//应用For循环语句对敏感词进行判断
		   if(preg_match("/".trim($filter_word[$i])."/i",$content)){		//应用正则表达式，判断传递的留言信息中是否含有敏感词
			  echo "<script>alert('留言信息中包含敏感词！');history.back(-1);</script>";
		 	  exit;
		   }
	    }
	}
	$sql="select count(*) as total from forum_message";
	$result=mysql_query($sql);
	$info=mysql_fetch_array($result);
	$total=$info[total];
	$id=$total+1;
	$user=$_POST['user'];
	$email=$_POST['email'];
	$ip=$_SERVER["REMOTE_ADDR"];
	$createtime=date("Y-m-d H:i:s");
	if(mysql_query("insert into forum_message(id,user,email,ip,createtime,content)values('$id','$user','$email','$ip','$createtime','$content')")){
	   echo "<script>alert('留言发表成功！');window.location.href='message.php'</script>";
	}else{
	   echo "<script>alert('留言发表失败！');history.back();</script>";
	}
}
?>
<?php
	include("footer.php");
?>
</body>
</html>
